﻿<UserControl x:Class="FIFP.DashBoard.Views.UCAppointment"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:converter="clr-namespace:FIFP.DashBoard.Converters"
    xmlns:vm="clr-namespace:FIFP.DashBoard.ViewModel"
    
    xmlns:Presentation="clr-namespace:FIFP.Common.Behaviors.CommonEventArgs;assembly=FIFP.Common"
    mc:Ignorable="d">
    

    <UserControl.Resources>
        <!--<converter:ViewDefinitionToBooleanConverter x:Key="ViewDefinitionToBooleanConverter" />-->
        <DataTemplate x:Key="AppointmentToolTipTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Text="Division: "/>
                <TextBlock Text="{Binding Path=Appointment.Division}" Grid.Column="1"/>
                <TextBlock Grid.Row="1" Text="UnitName: "/>
                <TextBlock Grid.Row="1" Text="{Binding Path=Appointment.UnitName}" Grid.Column="1"/>
                <TextBlock Grid.Row="2" Text="UnitType: "/>
                <TextBlock Grid.Row="2" Text="{Binding Path=Appointment.UnitType}" Grid.Column="1"/>
                <TextBlock Grid.Row="3" Text="ActivityType: "/>
                <TextBlock Grid.Row="3" Text="{Binding Path=Appointment.ActivityType}" Grid.Column="1"/>
                <TextBlock Grid.Row="4" Text="Start: "/>
                <TextBlock Grid.Row="4" Text="{Binding Path=Appointment.Start}" Grid.Column="1"/>
                <TextBlock Grid.Row="5" Text="End: "/>
                <TextBlock Grid.Row="5" Text="{Binding Path=Appointment.End}" Grid.Column="1"/>
            </Grid>
            
        </DataTemplate>

        <SolidColorBrush x:Key="GroupHeaderForeground" Color="#B2020202" />

        <converter:OrientedGroupHeaderContentTemplateSelector x:Key="GroupHeaderContentTemplateSelector">
            <!-- Default templates: -->
            <converter:OrientedGroupHeaderContentTemplateSelector.HorizontalMonthViewDateTemplate>
                <DataTemplate>
                    <TextBlock Margin="4" Text="{Binding Name, StringFormat=%d MMM}"/>
                </DataTemplate>
                </converter:OrientedGroupHeaderContentTemplateSelector.HorizontalMonthViewDateTemplate>
                <converter:OrientedGroupHeaderContentTemplateSelector.HorizontalDayViewDateTemplate>
                <DataTemplate>
                    <TextBlock Margin="4" Text="{Binding Name, StringFormat=dd dddd}"/>
                </DataTemplate>
                </converter:OrientedGroupHeaderContentTemplateSelector.HorizontalDayViewDateTemplate>
                <converter:OrientedGroupHeaderContentTemplateSelector.HorizontalWeekViewDateTemplate>
                <DataTemplate>
                    <TextBlock Margin="4" Text="{Binding Name, StringFormat=dd dddd}"/>
                </DataTemplate>
                </converter:OrientedGroupHeaderContentTemplateSelector.HorizontalWeekViewDateTemplate>
                <converter:OrientedGroupHeaderContentTemplateSelector.HorizontalResourceTemplate>
                <DataTemplate>
                    <TextBlock Foreground="{StaticResource GroupHeaderForeground}" FontSize="16" Margin="0" Text="{Binding Name.DisplayName}" />
                </DataTemplate>
                </converter:OrientedGroupHeaderContentTemplateSelector.HorizontalResourceTemplate>
                <converter:OrientedGroupHeaderContentTemplateSelector.VerticalWeekViewDateTemplate>
                <DataTemplate>
                    <telerik:LayoutTransformControl>
                        <telerik:LayoutTransformControl.LayoutTransform>
                            <RotateTransform Angle="-90" />
                        </telerik:LayoutTransformControl.LayoutTransform>
                        <TextBlock Margin="4" Text="{Binding Name, StringFormat=dd dddd}" VerticalAlignment="Top" />
                    </telerik:LayoutTransformControl>
                </DataTemplate>
                </converter:OrientedGroupHeaderContentTemplateSelector.VerticalWeekViewDateTemplate>
                <converter:OrientedGroupHeaderContentTemplateSelector.VerticalDayViewDateTemplate>
                <DataTemplate>
                    <telerik:LayoutTransformControl>
                        <telerik:LayoutTransformControl.LayoutTransform>
                            <RotateTransform Angle="-90" />
                        </telerik:LayoutTransformControl.LayoutTransform>
                        <TextBlock Margin="4" Text="{Binding Name, StringFormat=dd dddd}" VerticalAlignment="Top" />
                    </telerik:LayoutTransformControl>
                </DataTemplate>
                </converter:OrientedGroupHeaderContentTemplateSelector.VerticalDayViewDateTemplate>

                <converter:OrientedGroupHeaderContentTemplateSelector.VerticalMonthViewDateTemplate>
                <DataTemplate>
                    <telerik:LayoutTransformControl>
                        <telerik:LayoutTransformControl.LayoutTransform>
                            <RotateTransform Angle="-90" />
                        </telerik:LayoutTransformControl.LayoutTransform>
                        <TextBlock Margin="4" Text="{Binding Name, StringFormat=%d MMM}" VerticalAlignment="Top" />
                    </telerik:LayoutTransformControl>
                </DataTemplate>
                </converter:OrientedGroupHeaderContentTemplateSelector.VerticalMonthViewDateTemplate>
                <converter:OrientedGroupHeaderContentTemplateSelector.VerticalResourceTemplate>
                <DataTemplate>
                    <TextBlock Foreground="{StaticResource GroupHeaderForeground}" Margin="-2 3 0 5" FontSize="16" Text="{Binding Name.DisplayName}" />
                </DataTemplate>
                </converter:OrientedGroupHeaderContentTemplateSelector.VerticalResourceTemplate>
        </converter:OrientedGroupHeaderContentTemplateSelector>


    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Left" Margin="0,0,0,10">
            <TextBlock Text="Zoom: " Style="{StaticResource SmallHeading}" VerticalAlignment="Center" Margin="0,0,10,0" />
            <telerik:RadSlider Width="150" Minimum="{Binding ActualHeight, ElementName=radView}" Maximum="5000" Margin="0" Style="{StaticResource RadSliderStyle1}"
						VerticalAlignment="Center" Value="{Binding ActiveViewDefinition.MinTimeRulerExtent, ElementName=radView, Mode=TwoWay}" LargeChange="50" />
           
        </StackPanel>
        
        <telerik:RadScheduleView  ToolTipTemplate="{StaticResource AppointmentToolTipTemplate}" Grid.Row="1" x:Name="radView" ActiveViewDefinitionIndex="3"
                                 AppointmentsSource="{Binding Appointments}" GroupHeaderStyleSelector="{StaticResource GroupHeaderStyleSelector}" ResourceTypesSource="{Binding ResourceTypes}" 
                                 GroupDescriptionsSource="{Binding GroupTypes}" EditAppointmentDialogStyle="{StaticResource EditAppointmentDialogStyle}" 
                                 NavigationHeaderVisibility="{Binding NavigationVisibility}" CurrentDate="{Binding StartDate}" Background="#FF303440" BorderBrush="#FF303440" 
                                 GroupHeaderContentTemplateSelector="{StaticResource GroupHeaderContentTemplateSelector}">

            
            <i:Interaction.Triggers>
               
                
                <i:EventTrigger EventName="AppointmentCreating">
                    <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.AppointmentCreateCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                    
                </i:EventTrigger>

                <i:EventTrigger EventName="AppointmentEditing">
                    <i:InvokeCommandAction Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.AppointmentEditingCommand}" CommandParameter="{Binding ElementName=radView}" />
                </i:EventTrigger>
                
                <i:EventTrigger EventName="AppointmentEdited">
                    <i:InvokeCommandAction Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.AppointmentEditCommand}" CommandParameter="{Binding ElementName=radView}" />
                </i:EventTrigger>

                <i:EventTrigger EventName="AppointmentDeleted">
                    <i:InvokeCommandAction Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.AppointmentDeleteCommand}" CommandParameter="{Binding ElementName=radView}" />
                </i:EventTrigger>

            </i:Interaction.Triggers>
            
            <telerik:RadScheduleView.ViewDefinitions>
                <telerik:DayViewDefinition MinTimeRulerExtent="1" MinorTickLength="{Binding MajorTickLength}" MajorTickLength="{Binding MajorTickLength}" 
						VisibleDays="{Binding VisibleDays}" AppointmentFilter="{Binding FilterValue}">
                </telerik:DayViewDefinition>
                <telerik:WeekViewDefinition MinTimeRulerExtent="1" MinorTickLength="{Binding MajorTickLength}" MajorTickLength="{Binding MajorTickLength}" 
						VisibleDays="{Binding VisibleDays}" AppointmentFilter="{Binding FilterValue}">
                </telerik:WeekViewDefinition>
                <telerik:MonthViewDefinition MinTimeRulerExtent="1" TimerulerGroupStringFormat="{}{0:MMM,yyyy}" 
						VisibleDays="{Binding VisibleDays}" AppointmentFilter="{Binding FilterValue}">
                </telerik:MonthViewDefinition>
                <telerik:TimelineViewDefinition MinTimeRulerExtent="1" MinorTickLength="{Binding MajorTickLength}" MajorTickLength="{Binding MajorTickLength}" GroupTickLength="{Binding GroupTickLength}" TimerulerGroupStringFormat="{}{0:MMM,yyyy}" 
						VisibleDays="{Binding VisibleDays}" AppointmentFilter="{Binding FilterValue}">
                </telerik:TimelineViewDefinition>

            </telerik:RadScheduleView.ViewDefinitions>

            
            <telerik:RadScheduleView.DragDropBehavior>
                <converter:ScheduleDragDropBehavior />
            </telerik:RadScheduleView.DragDropBehavior>
            
            <telerik:RadScheduleView.GroupHeaderContentTemplate>
                <DataTemplate>
                    <TextBlock Name="txtGroup" Foreground="White" Text="{Binding FormattedName}" Margin="0,0,10,0" Width="150" VerticalAlignment="Center" HorizontalAlignment="Right" TextAlignment="Right">
                        
                    </TextBlock>
                </DataTemplate>
            </telerik:RadScheduleView.GroupHeaderContentTemplate>

            <telerik:RadScheduleView.TimeRulerItemStyleSelector>
                <converter:GroupItemStyleSelector>
                    <converter:GroupItemStyleSelector.DefaultStyle>
                        <Style TargetType="Control">
                            <Setter Property="Width" Value="1" />
                            <Setter Property="Height" Value="0" />
						
                        </Style>
                    </converter:GroupItemStyleSelector.DefaultStyle>
                    <converter:GroupItemStyleSelector.GroupItemStyle>
                        <Style TargetType="telerik:TimeRulerGroupItem">
                        		<Setter Property="Foreground" Value="white" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="telerik:TimeRulerGroupItem">
                                        <Border BorderBrush="#FF303440" Background="#FF303440" BorderThickness="1 1 0 0">
                                            <ContentPresenter Margin="4 2" />
                                        </Border>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </converter:GroupItemStyleSelector.GroupItemStyle>
                    <converter:GroupItemStyleSelector.TimeRulerLineStyle>
                        <Style TargetType="Control">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="Control">
                                        <Border BorderBrush="#FF676364" Background="#FF676364" BorderThickness="1 0 0 0" />
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </converter:GroupItemStyleSelector.TimeRulerLineStyle>
                    </converter:GroupItemStyleSelector>
            </telerik:RadScheduleView.TimeRulerItemStyleSelector>            

        </telerik:RadScheduleView>

    </Grid>
</UserControl>
